<template>
  <div>
    <h1>温州理工滨海校区</h1>
    <div>
      <input v-model="studentId" placeholder="请输入学号">
      <button @click="searchStudent">查找</button>
    </div>
    <div v-if="studentInfo">
      <h3>学生信息</h3>
      <p>学号: {{ studentInfo.id }}</p>
      <p>姓名: {{ studentInfo.name }}</p>
      <p>专业: {{ studentInfo.major }}</p>
    </div>
    <div v-else-if="searched">
      <p>未找到该学生信息</p>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      studentId: '',
      studentInfo: null,
      searched: false,
      students: [
        { id: '2023001', name: '张三', major: '计算机科学与技术' },
        { id: '2023002', name: '李四', major: '软件工程' },
        { id: '2023003', name: '王五', major: '数据科学与大数据' }
      ]
    }
  },
  methods: {
    searchStudent() {
      this.studentInfo = this.students.find(s => s.id === this.studentId)
      this.searched = true
    }
  }
}
</script>